<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:53:"D:\GitCode\LayZy/application/admin\view\ad_index.html";i:1576124354;s:49:"D:\GitCode\LayZy\application\admin\view\base.html";i:1576323868;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>LaySNS后台管理</title>
<link rel="stylesheet" href="/public/plugins/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="/public/css/main.css" media="all" /> 
<link rel="stylesheet" href="/public/css/font.css">
<link rel="stylesheet" href="/public/css/admin.css">
<link rel="stylesheet" href="/public/css/form.css"> 
<script src="/public/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/public/plugins/layui/layui.js"></script>
</head>

<body>

    <!--主体-->
    <div style="margin-bottom:36px;">

        
<div class="admin-main layui-form">
    <div class="layui-field-box">
        <div class="layui-box-searchber" style="overflow: visible">
            <button class="layui-btn layui-btn-danger layui-btn-sm" data-url="<?php echo url('admin/ad/alldelete'); ?>" lay-submit lay-filter="alldelete">删除选中</button>
            <a class="layui-btn layui-btn-success layui-btn-sm" href="<?php echo url('admin/ad/add'); ?>" lay-submit>添加广告</a>
          
            <form class="layui-form-pane" action="<?php echo url('admin/ad/index'); ?>" method="get">

                <div class="layui-form">
                    <div class="layui-inline" style="width:100px">
                        <select name="status" lay-filter="selectstatus">
                                <option  value="">状态</option>
                                <option <?php if($status == '0'): ?>selected="selected"<?php endif; ?> value="0">隐藏</option>
                                <option <?php if($status == 1): ?>selected="selected"<?php endif; ?> value="1">显示</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">关键字</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="<?php echo $keyword; ?>"  placeholder="广告名/链接/QQ" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-sm">搜索</button>
                    </div>
                </div>
            </form>
        </div>
        <hr>
        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="20px" align="center"><input type="checkbox" name="checkAll" lay-filter="checkAll"></th>
                    <th style="text-align:center">广告位置</th>
                    <th width="50px" style="text-align:center">排序</th>
                    <th style="text-align:center;max-height: 100px">广告图及链接</th>
                    <th style="text-align:center">投放起止日期</th>
                    <th style="text-align:center">显示状态</th>
                    <th style="text-align:center">投放人QQ</th>
                    <th width="110px" style="text-align:center">操作</th>
                </tr>
            </thead>
            <tbody id="content">
                <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                <tr>
                    <td align="center"><input type="checkbox" name="ids[<?php echo $vo['id']; ?>]" lay-filter="checkOne" value="<?php echo $vo['id']; ?>"></td>
                    <td align="center"><?php echo $vo['location']; ?></td>
                    <td align="center"><?php echo $vo['sort']; ?></td>
                    <td align="center"><a target="_blank" href="<?php echo $vo['link']; ?>" ><img src="<?php echo $vo['banner_path']; ?>" style="height:70px "/></a></td>
                    <td align="center">起：<?php echo substr($vo['start_time'], 0, 10); ?><br>止：<?php echo substr($vo['finish_time'], 0, 10); ?></td>
                    <td align="center">
                        <input type="checkbox" name="show" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchstatus" value="<?php echo $vo['id']; ?>" <?php echo $vo[ 'status']==1 ? 'checked' : ''; ?>>
                    </td>
                    <td align="center">  <a style="点击可打开QQ" href="http://wpa.qq.com/msgrd?v=3&amp;uin=<?php echo $vo['poster_qq']; ?>&amp;site=qq&amp;menu=yes" target="_blank"><?php echo $vo['poster_qq']; ?></a>
                    </td>
                    <td align="center">
                        <a class="layui-btn layui-btn-normal layui-btn-sm" href="<?php echo url('admin/ad/edit',array('id'=>$vo['id'])); ?>">修改</a>
                        <a class="elementdel layui-btn layui-btn-danger layui-btn-sm" href="javascript:;" data-id="<?php echo $vo['id']; ?>" data-url="<?php echo url('admin/ad/delete',array('id'=>$vo['id'])); ?>" title="删除">删除</a>
                    </td>
                </tr>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            </tbody>
        </table>
    </div>


</div>

    </div>

    
<div class="btable-paged">
    <div class="formbtngroup">
        <?php echo $list->render(); ?>
    </div>
</div>


    <script>
        var token = '<?php echo $token; ?>';
    </script> 
<script type="text/javascript" src="/public/js/delelement.js"></script>

    <!--页面JS脚本-->
    

<script>
    layui.use(['form', 'laydate'], function() {
        var form = layui.form,
            laydate = layui.laydate,
            $form = $('form'),
            jq = layui.jquery;
        form.on('select()', function(data) {
            $form.submit();
        });

        laydate.render({
            elem: '#startdate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        laydate.render({
            elem: '#enddate' //指定元素
                ,
            done: function(value, date) {
                $form.submit();
            }
        });
        var status = 0;
        form.on('switch(switchstatus)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "<?php echo url('admin/ad/toggle'); ?>?id=" + data.value + '&status=' + status + '&name=status';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        form.on('switch(switchchoice)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "<?php echo url('admin/ad/toggle'); ?>?id=" + data.value + '&status=' + status + '&name=choice';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchsettop)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "<?php echo url('admin/ad/toggle'); ?>?id=" + data.value + '&status=' + status + '&name=settop';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        form.on('switch(switchmemo)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "<?php echo url('admin/ad/toggle'); ?>?id=" + data.value + '&status=' + status + '&name=memo';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

    })
</script>

</body>

</html>